package com.redStudio.queryTest.controller;

import java.util.List;

import org.hamcrest.core.IsNull;
import org.mockito.BDDMockito.Then;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.redStudio.queryTest.modal.MondataDaily;
import com.redStudio.queryTest.repository.MondataDailyRepository;


@RestController
@RequestMapping("/mon_data_dailyList")
public class MondataDailyController {
	@Autowired
	private MondataDailyRepository repo;
	
	@RequestMapping(method = RequestMethod.GET)
	public List<MondataDaily> findAllList(){
		return repo.findAllList();
	}
	
	private String addPercentStr(String val){
		val = val.trim();
		if (val.trim().isEmpty()) {
			val = "%";
		}
		else{
			val = "%" + val + "%"; 
		}
		return val;
	}
	public List<MondataDaily> findListByParam(String area_name,
																					String mon_point_name,
																					String dev_mn,
																					String data_type_name){

		return repo.findListByParam(
				addPercentStr(area_name),
				addPercentStr(mon_point_name),
				addPercentStr(dev_mn),
				addPercentStr(data_type_name));
	}

}
